package com.github.common.extend.demo.config.filetask.download;

import com.github.common.extend.demo.config.filetask.FileTaskCallback;
import com.github.common.extend.demo.config.filetask.FileTaskParam;
import javax.servlet.http.HttpServletResponse;
import java.util.concurrent.TimeUnit;

/**
 * 文件任务下载器
 * @author wangjj7
 * @date 2023/8/29
 * @description
 */
public interface FileTaskDownloader {

    /**
     * 提交文件生成任务，成功执行后下载
     * @param fileTaskParam
     * @param response
     */
    void submitTaskThenDownload(FileTaskParam fileTaskParam, HttpServletResponse response);

    /**
     * 异步提交文件生成任务，成功执行后下载
     * @param fileTaskParam
     * @param fileTaskCallback
     * @param response
     * @param timeout
     * @param timeUnit
     */
    void asyncSubmitTaskThenDownload(FileTaskParam fileTaskParam, FileTaskCallback fileTaskCallback,
                                     HttpServletResponse response, long timeout, TimeUnit timeUnit);

    /**
     * 重载
     * @see #asyncSubmitTaskThenDownload(FileTaskParam, FileTaskCallback ,HttpServletResponse, long, TimeUnit)
     */
    default void asyncSubmitTaskThenDownload(FileTaskParam fileTaskParam, HttpServletResponse response,
                                             long timeout, TimeUnit timeUnit)
    {
        asyncSubmitTaskThenDownload(fileTaskParam, null ,response, timeout, timeUnit);
    }


}
